package cn.toolck.login_demo.controller;

import cn.toolck.login_demo.pojo.User;
import cn.toolck.login_demo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @ClassName LoginController
 * @Description TODO
 * @Author Toolck Rin
 * @Date 2021/3/23 21:12
 * @Version 1.0
 **/
@Controller
@RequestMapping("login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @RequestMapping("toLogin")
    public String toLogin() {
        return "login";
    }

    @RequestMapping("/loginSystem")
    public String doLogin(User user, HttpSession session) {
        boolean login = loginService.login(user, session);
        if (login) {
            return "redirect:/demo/result";
        }
        return "redirect:/login/toLogin";
    }
}
